package jp.sourceforge.akjrcp.dropsomething;


import jp.sourceforge.akjrcp.akj_betas.Messages;
import jp.sourceforge.akjrcp.dropsomething.MPEGConvertTabBuilder.MPEGConvertTab;
import jp.sourceforge.akjrcp.dropsomething2.DropFileGenericParameterSetting;
import jp.sourceforge.akjrcp.ui.AbstractGenericParametersOptionEditor;
import jp.sourceforge.akjrcp.ui.GenericParameters;
import jp.sourceforge.akjrcp.ui.param.ParamBoolean;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.part.ViewPart;



public class FFMpegConvertTabBuilder implements IDropSomething{
	public static Log log=LogFactory.getLog(FFMpegConvertTabBuilder.class);
	public static final String PREFERENCE_KEY=FFMpegSettingPage.EXPORT_KEYNAME;
	
	private DropsomethingTab dtab;
	private CTabItem tabItem1 ;
	
	public void createControl(final ViewPart part,final CTabFolder tab) {
		if(dtab==null){
			//deley create control
			dtab=new FFMpegConvertTab(tab,SWT.NULL);

			dtab.setViewPart(part);
			tabItem1.setControl(dtab);
		}
	}
	
	public void createTab(ViewPart part, CTabFolder tab) {
		 tabItem1 = new CTabItem(tab, SWT.NONE);
		
		
		//custom below
		tabItem1.setText(Messages.getString("ffmpegconvert.tab"));
		
	}
	
	public class FFMpegConvertTab extends AbstractFFMpegDropSomething{

		
		
		public FFMpegConvertTab(Composite parent, int style) {
			super(parent, style,PREFERENCE_KEY);
		}
		/**
		 * return genericParamater,when new button clicked or none selected
		 * 
		 */
		
		public  GenericParameters makeDefaultGenericParameters(){
			GenericParameters parameters=new GenericParameters();
			
			//parameters.set("b", "2500k");
			parameters.set("EXTENSION", "mpg");
			//parameters.set("ab", "128k");
			return parameters;
		}
		
		public class CustomFFMpegOptionEditor extends FFMpegOptionEditor{
			public Composite createOtherControls(Composite parent) {
				//createDirectoryInfo(parent);
				
				//SavePreferenceStore savePreference=new SavePreferenceStore();//for save controls
				avisynth = new ParamBoolean(parent, SWT.CHECK,DropFileGenericParameterSetting.USE_AVISYNTH,Messages.getString("pspconvert.use_avisynth"),false);
				avisynth.setToolTipText(Messages
						.getString("pspconvert.use_avisynth_tooltip"));
				//TODO rethink save system.
				addParamList(avisynth);
				
				dragHere=new Label(parent,SWT.NULL);
				dragHere.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
				
				//restoreControl(avisynth);
				return parent;
			}
		}
		
		
		public  AbstractGenericParametersOptionEditor makeGenericParameterOptionEditor(){
			return new CustomFFMpegOptionEditor();
		}

		
		
		
		
	}
	

	

	
	
}
